package it.irondev.appturismo.dao;

import it.irondev.appturismo.dao.example.CityExample;
import it.irondev.appturismo.dao.provider.CitySqlProvider;
import it.irondev.appturismo.entity.City;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface CityMapper {
    @SelectProvider(type=CitySqlProvider.class, method="countByExample")
    int countByExample(CityExample example);

    @DeleteProvider(type=CitySqlProvider.class, method="deleteByExample")
    int deleteByExample(CityExample example);

    @Delete({
        "delete from City",
        "where idCity = #{idcity,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer idcity);

    @Insert({
        "insert into City (idCity, name, ",
        "description)",
        "values (#{idcity,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{description,jdbcType=VARCHAR})"
    })
    int insert(City record);

    @InsertProvider(type=CitySqlProvider.class, method="insertSelective")
    int insertSelective(City record);

    @SelectProvider(type=CitySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="idCity", property="idcity", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR)
    })
    List<City> selectByExample(CityExample example);

    @Select({
        "select",
        "idCity, name, description",
        "from City",
        "where idCity = #{idcity,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="idCity", property="idcity", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR)
    })
    City selectByPrimaryKey(Integer idcity);

    @UpdateProvider(type=CitySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") City record, @Param("example") CityExample example);

    @UpdateProvider(type=CitySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") City record, @Param("example") CityExample example);

    @UpdateProvider(type=CitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(City record);

    @Update({
        "update City",
        "set name = #{name,jdbcType=VARCHAR},",
          "description = #{description,jdbcType=VARCHAR}",
        "where idCity = #{idcity,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(City record);
}